// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import VueAMap, {lazyAMapApiLoaderInstance} from 'vue-amap';
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import router from './router'
import axios from 'axios'
import VueWechatTitle from 'vue-wechat-title';
import 'babel-polyfill'

require('font-awesome-webpack');
Vue.use(VueWechatTitle)


Vue.prototype.getCookie = function (name) {
  let arr = document.cookie.replace(/\s/g, "").split(';');
  for (let i = 0; i < arr.length; i++) {
    let tempArr = arr[i].split('=');
    if (tempArr[0] === name) {
      return decodeURIComponent(tempArr[1]);
    }
  }
  return '';
};

Vue.prototype.setCookie = function (name, value) {
  document.cookie = name + '=' + value;
};


Vue.config.productionTip = false
Vue.use(ElementUI);
Vue.use(VueAMap);
VueAMap.initAMapApiLoader({
  key: '99ad39962583b459989e947d596121a6',
  plugin: ['AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.Geolocation'],
  uiVersion: '1.0',// ui库版本，不配置不加载,
  v: '1.4.4'
});

lazyAMapApiLoaderInstance.load().then(() => {
});


axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
//封装axios
const instance = axios.create({
  timeout: 10000,
  withCredentials: true,//跨域
});
Vue.prototype.axios = instance;

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: {App},
  template: '<App/>'
})
